﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerAnimation : MonoBehaviour
{
    private Animator anim;
    private Rigidbody2D rb;
    private PlayerConllter playerConllter;
    // Start is called before the first frame update
    void Start()
    {
        anim = GetComponent<Animator>();
        rb = GetComponent<Rigidbody2D>();
        playerConllter = GetComponent<PlayerConllter>();
    }

    // Update is called once per frame
    void Update()
    {
        //Mathf.Abs 取绝对值，-1 转 1
        //Set 可以设置动画控制器中的属性
        anim.SetFloat("speed",Mathf.Abs(rb.velocity.x));
        anim.SetBool("isJump",playerConllter.isJump);
        anim.SetBool("isGround",playerConllter.isGround);
    }
}
